import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'widgets/header.dart';

class Team extends StatefulWidget {
  @override
  _NestedScrollViewWidgetState createState() => _NestedScrollViewWidgetState();
}

class _NestedScrollViewWidgetState extends State<Team> {
  List<String> _tabs = ["参加过", "被邀请"];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Material(
        child: Column(
      children: <Widget>[
        Expanded(
          child: DefaultTabController(
            length: _tabs.length, // This is the number of tabs.
            child: NestedScrollView(
              headerSliverBuilder:
                  (BuildContext context, bool innerBoxIsScrolled) {
                return <Widget>[
                  SliverOverlapAbsorber(
                    handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
                        context),
                    sliver: SliverAppBar(
                      title: const Text('团队'),
                      elevation: 0,
                      pinned: true,
                      expandedHeight: 370.0,
                      centerTitle: true,
                      flexibleSpace: FlexibleSpaceBar(
                          background: Stack(
                        children: [
//                                  Align(
//                                    alignment: Alignment.center,
//                                    child: Container(
//                                      width: double.infinity,
//                                        child: Image.network("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhimg2.huanqiu.com%2Fattachment2010%2F2013%2F0309%2F20130309104448793.jpg&refer=http%3A%2F%2Fhimg2.huanqiu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1622279160&t=1174baf81aaa1c12e0fcb1a2fc2cd62b",fit: BoxFit.cover,),
//                                      )
//                                  ),
                          Positioned(
                            bottom: 40,
                            child: Teamheader(),
                          )
                        ],
                      )),
                      bottom: TabBar(
                        tabs: _tabs
                            .map((String name) => Tab(text: name))
                            .toList(),
                      ),
                    ),
                  ),
                ];
              },
              body: TabBarView(
                children: _tabs.map((String name) {
                  return SafeArea(
                    top: false,
                    bottom: false,
                    child: Builder(
                      builder: (BuildContext context) {
                        if (name == "参加过") {
                          return Center(
                            child: Text("参加过"),
                          );
                        } else if (name == "被邀请") {
                          return Center(child: Text("被邀请"));
                        }
                      },
                    ),
                  );
                }).toList(),
              ),
            ),
          ),
        ),
      ],
    ));
  }
}
